'use strict';

const mongoose = require('mongoose');
const { TeamType } = require('./team.js');
const { LeagueType } = require('./league.js');

const Schema = mongoose.Schema;

const MatchType = {
    id: Schema.ObjectId,
    home: TeamType,
    away: TeamType,
    league: LeagueType,
    homeScore: {
        type: Number,
        default: 0,
    },
    awayScore: {
        type: Number,
        default: 0,
    },
    startTime: {
        type: Date,
        default: Date.now
    },
    endTime: {
        type: Date,
        default: Date.now
    },
    createTime: {
        type: Date,
        default: Date.now
    },
    status: {
        type: String,
        enum: ['0', '1', '2', '3'], // 0: 未开始, 1:进行中, 2:已结束, 3:已取消
        default: '0'
    }, 
};

const MatchSchema = new Schema(MatchType);

module.exports = {
    MatchType,
    MatchSchema,
    MatchModel: mongoose.model('MatchModel', MatchSchema),
}